unit Options;

interface

uses
  Color, Sounds,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, Mask, Grids, DB, DBTables, MPlayer, ComCtrls, Menus,
  FileCtrl, ColorGrd, JvExMask, JvSpin, JvDBSpinEdit, DBGrids, SMDBGrid;

type
  TFormOptions = class(TForm)
    DialogColor: TColorDialog;
    TabOptions: TPageControl;
    PageMessages: TTabSheet;
    PageStatusBars: TTabSheet;
    BoxStatusBarIntervals: TGroupBox;
    c1001: TShape;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    cl1: TShape;
    cm1: TShape;
    ch1: TShape;
    Label6: TLabel;
    Label14: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    ImageHP: TImage;
    ImageSP: TImage;
    ImageGP1: TImage;
    ImageGP2: TImage;
    ImageEnemy: TImage;
    b11: TBitBtn;
    bl1: TBitBtn;
    bm1: TBitBtn;
    bh1: TBitBtn;
    PanelButtonbar: TPanel;
    BtnClear: TBitBtn;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    BoxMessageOptions: TGroupBox;
    Label3: TLabel;
    cl2: TShape;
    bl2: TBitBtn;
    cl3: TShape;
    bl3: TBitBtn;
    cl4: TShape;
    bl4: TBitBtn;
    cl5: TShape;
    BtnEnemyLow: TBitBtn;
    cm2: TShape;
    bm2: TBitBtn;
    bh2: TBitBtn;
    ch2: TShape;
    cm3: TShape;
    bm3: TBitBtn;
    bh3: TBitBtn;
    ch3: TShape;
    cm4: TShape;
    bm4: TBitBtn;
    bh4: TBitBtn;
    ch4: TShape;
    cm5: TShape;
    BtnEnemyMedian: TBitBtn;
    BtnEnemyHigh: TBitBtn;
    ch5: TShape;
    Bevel1: TBevel;
    Bevel2: TBevel;
    Bevel5: TBevel;
    Bevel6: TBevel;
    c1002: TShape;
    b12: TBitBtn;
    c1003: TShape;
    b13: TBitBtn;
    c1004: TShape;
    b14: TBitBtn;
    c1005: TShape;
    BtnEnemy: TBitBtn;
    co1: TShape;
    bo1: TBitBtn;
    co2: TShape;
    bo2: TBitBtn;
    co3: TShape;
    bo3: TBitBtn;
    co4: TShape;
    bo4: TBitBtn;
    co5: TShape;
    BtnEnemyBetter: TBitBtn;
    PageText: TTabSheet;
    MainMenu: TMainMenu;
    MenuHelp: TMenuItem;
    PageGlobal: TTabSheet;
    PageCommandLine: TTabSheet;
    BoxRetain: TGroupBox;
    CheckRetain: TCheckBox;
    LabelNew: TLabel;
    EditRetain: TEdit;
    BtnAdd: TBitBtn;
    BtnDelete: TBitBtn;
    RetainCheckSpace: TCheckBox;
    CheckRetainAll: TCheckBox;
    BoxEchoTextOptions: TGroupBox;
    Bevel7: TBevel;
    Bevel4: TBevel;
    Bevel99: TBevel;
    Bevel88: TBevel;
    Bevel3: TBevel;
    ColorAutotyper: TLabel;
    ColorTyped: TLabel;
    ColorMacros: TLabel;
    ColorAliases: TLabel;
    ColorEvents: TLabel;
    Bevel8: TBevel;
    ColorPasted: TLabel;
    BtnColorTyped: TBitBtn;
    BtnColorAutotyper: TBitBtn;
    BtnColorMacros: TBitBtn;
    BtnColorAliases: TBitBtn;
    CheckAliases: TCheckBox;
    CheckMacros: TCheckBox;
    CheckAutotyper: TCheckBox;
    CheckTyped: TCheckBox;
    CheckEvents: TCheckBox;
    BtnColorEvents: TBitBtn;
    CheckPasted: TCheckBox;
    BtnColorPasted: TBitBtn;
    BtnClearAll: TBitBtn;
    BoxGlobal: TGroupBox;
    CheckWarnings: TCheckBox;
    PageReversing: TTabSheet;
    BoxReversing: TGroupBox;
    EditRCommand: TEdit;
    BtnRAdd: TBitBtn;
    Label35: TLabel;
    Label36: TLabel;
    EditRReverse: TEdit;
    CheckDuplicate: TCheckBox;
    BtnRDelete: TBitBtn;
    Label38: TLabel;
    CheckNTyped: TCheckBox;
    CheckNAutotyper: TCheckBox;
    CheckNPasted: TCheckBox;
    CheckNAliases: TCheckBox;
    CheckNMacros: TCheckBox;
    CheckNEvents: TCheckBox;
    CheckDTyped: TCheckBox;
    CheckDAutotyper: TCheckBox;
    CheckDPasted: TCheckBox;
    CheckDAliases: TCheckBox;
    CheckDMacros: TCheckBox;
    CheckDEvents: TCheckBox;
    Label39: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    CheckDParsed: TCheckBox;
    CheckDTicker: TCheckBox;
    CheckDQuickchars: TCheckBox;
    Label43: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    Label49: TLabel;
    Label50: TLabel;
    Label51: TLabel;
    Label52: TLabel;
    CheckEQuickchars: TCheckBox;
    CheckEParsed: TCheckBox;
    CheckETicker: TCheckBox;
    CheckNQuickchars: TCheckBox;
    CheckNTicker: TCheckBox;
    CheckNParsed: TCheckBox;
    Bevel16: TBevel;
    Bevel18: TBevel;
    Bevel19: TBevel;
    BtnQuickchars: TBitBtn;
    BtnParsed: TBitBtn;
    BtnTicker: TBitBtn;
    ColorQuickchars: TLabel;
    ColorTicker: TLabel;
    ColorParsed: TLabel;
    PageFTP: TTabSheet;
    BoxFTPLocal: TGroupBox;
    CheckLocalDir: TCheckBox;
    DirectoryLocal: TDirectoryListBox;
    ComboLocal: TDriveComboBox;
    CheckOverwriteLocal: TCheckBox;
    CheckBTyped: TCheckBox;
    CheckBAutotyped: TCheckBox;
    CheckBPasted: TCheckBox;
    CheckBAliases: TCheckBox;
    CheckBMacros: TCheckBox;
    CheckBEvents: TCheckBox;
    CheckBQuickchars: TCheckBox;
    CheckBTicker: TCheckBox;
    CheckBParsed: TCheckBox;
    CheckVTyped: TCheckBox;
    CheckVAutotyped: TCheckBox;
    CheckVPasted: TCheckBox;
    CheckVAliases: TCheckBox;
    CheckVMacros: TCheckBox;
    CheckVEvents: TCheckBox;
    CheckVQuickchars: TCheckBox;
    CheckVTicker: TCheckBox;
    CheckVParsed: TCheckBox;
    Label56: TLabel;
    BtnHelp: TBitBtn;
    Label57: TLabel;
    Label58: TLabel;
    CheckFTyped: TCheckBox;
    CheckFAutotyped: TCheckBox;
    CheckFPasted: TCheckBox;
    CheckFAliases: TCheckBox;
    CheckFMacros: TCheckBox;
    CheckFEvents: TCheckBox;
    CheckFQuickchars: TCheckBox;
    CheckFTicker: TCheckBox;
    CheckFParsed: TCheckBox;
    Label60: TLabel;
    BoxDelayedText: TGroupBox;
    Label61: TLabel;
    BoxFTPUpload: TGroupBox;
    BitBtn2: TBitBtn;
    CheckDelayUpload: TCheckBox;
    Bevel15: TBevel;
    Label67: TLabel;
    ColorSprint: TLabel;
    CheckDSprint: TCheckBox;
    CheckESprint: TCheckBox;
    CheckNSprint: TCheckBox;
    BtnSprint: TBitBtn;
    CheckBSprint: TCheckBox;
    CheckVSprint: TCheckBox;
    CheckFSprint: TCheckBox;
    CheckPersistentCLH: TCheckBox;
    PageKeyhistory: TTabSheet;
    GroupBox2: TGroupBox;
    Label7: TLabel;
    Label4: TLabel;
    Well1: TEdit;
    Label68: TLabel;
    Well2: TEdit;
    Label69: TLabel;
    Well3: TEdit;
    Label70: TLabel;
    Well4: TEdit;
    Label71: TLabel;
    Well5: TEdit;
    Label72: TLabel;
    CheckEnableChat: TCheckBox;
    CheckEnableTell: TCheckBox;
    CheckHP: TCheckBox;
    CheckSP: TCheckBox;
    CheckGP1: TCheckBox;
    CheckGP2: TCheckBox;
    CheckEnemy: TCheckBox;
    Label10: TLabel;
    Bevel20: TBevel;
    BtnHP4Left: TBitBtn;
    Color21: TShape;
    Color22: TShape;
    BtnHP4Right: TBitBtn;
    Bevel21: TBevel;
    CheckTruncate: TCheckBox;
    CheckAutoExpand: TCheckBox;
    CheckHighlightKeyhistory: TCheckBox;
    BoxMiscTextOptions: TGroupBox;
    CheckAutocopy: TCheckBox;
    CheckPCorrect: TCheckBox;
    CheckMaskPassword: TCheckBox;
    CheckFullFlash: TCheckBox;
    CheckPureLine: TCheckBox;
    CheckTab: TCheckBox;
    BoxSpecialCharacters: TGroupBox;
    Label9: TLabel;
    Label12: TLabel;
    EditActivator: TComboBox;
    EditQuickchar: TComboBox;
    Bevel11: TBevel;
    Bevel9: TBevel;
    ColorSystem: TLabel;
    ColorSelected: TLabel;
    Label13: TLabel;
    Label11: TLabel;
    BtnColorSelected: TBitBtn;
    BtnColorSystem: TBitBtn;
    Bevel14: TBevel;
    ColorHyperlink: TLabel;
    Label59: TLabel;
    BtnColorHyperlinks: TBitBtn;
    CheckEnableHyperlinks: TCheckBox;
    Bevel23: TBevel;
    Label74: TLabel;
    CheckDisableAliasLED: TCheckBox;
    CheckPanicLock: TCheckBox;
    CheckMenu: TCheckBox;
    CheckPageup: TCheckBox;
    CheckFeed: TCheckBox;
    CheckLabels: TCheckBox;
    CheckClearSending: TCheckBox;
    CheckEscape: TCheckBox;
    CheckAltF4: TCheckBox;
    Panel1: TPanel;
    Status: TLabel;
    BtnGauges: TBitBtn;
    Color666: TShape;
    CheckShowText: TCheckBox;
    Label2: TLabel;
    Label62: TLabel;
    Label63: TLabel;
    Label73: TLabel;
    Label33: TLabel;
    Label34: TLabel;
    EditHPMask: TEdit;
    EditSPMask: TEdit;
    MaskGP1: TEdit;
    MaskGP2: TEdit;
    Label1: TLabel;
    Bevel12: TBevel;
    CheckStatus: TCheckBox;
    CheckScrollExit: TCheckBox;
    CheckIdle: TCheckBox;
    Label5: TLabel;
    Label40: TLabel;
    Label53: TLabel;
    Label65: TLabel;
    CheckPanicBeep: TCheckBox;
    PageMedia: TTabSheet;
    BoxMedia: TGroupBox;
    Label75: TLabel;
    Label8: TLabel;
    Label37: TLabel;
    Label76: TLabel;
    Bevel24: TBevel;
    Label77: TLabel;
    Bevel22: TBevel;
    BtnSetSound: TBitBtn;
    EditSound: TEdit;
    BtnPlaySound: TBitBtn;
    BtnClearBeep: TBitBtn;
    CheckSounds: TCheckBox;
    CheckEnableRemote: TCheckBox;
    CheckAutoDownload: TCheckBox;
    CheckAutoExpandImagery: TCheckBox;
    CheckAutoShowImagery: TCheckBox;
    CheckNotify: TCheckBox;
    CheckAutoPlay: TCheckBox;
    BoxSecondary: TGroupBox;
    Label66: TLabel;
    ColorPrimary: TShape;
    Label78: TLabel;
    ColorSecondary: TShape;
    Label54: TLabel;
    Bevel10: TBevel;
    CheckSecondaryColor: TCheckBox;
    EditSecondaryPrompt: TEdit;
    CheckAutoKillSecondary: TCheckBox;
    BtnPrimary: TBitBtn;
    BtnSecondary: TBitBtn;
    Check2Italics: TCheckBox;
    ColorGrid: TColorGrid;
    CheckWarnBreak: TCheckBox;
    CheckBackup: TCheckBox;
    Label55: TLabel;
    CheckActiveKeyhistory: TCheckBox;
    CheckForced: TCheckBox;
    GroupBox3: TGroupBox;
    Label79: TLabel;
    Label80: TLabel;
    CheckTabLowercase: TCheckBox;
    CheckTabCompletion: TCheckBox;
    EditTab1: TEdit;
    EditTab5: TEdit;
    EditTab2: TEdit;
    EditTab6: TEdit;
    EditTab7: TEdit;
    EditTab3: TEdit;
    EditTab8: TEdit;
    EditTab4: TEdit;
    Label81: TLabel;
    CheckReconnect: TCheckBox;
    BoxFTPOther: TGroupBox;
    CheckCopyFilename: TCheckBox;
    Label64: TLabel;
    CheckProfanity: TCheckBox;
    DSRetain: TDataSource;
    DSReverse: TDataSource;
    SpinScroll: TJvDBSpinEdit;
    SpinIdle: TJvDBSpinEdit;
    SpinLinewrap: TJvDBSpinEdit;
    SpinIH: TJvDBSpinEdit;
    SpinIW: TJvDBSpinEdit;
    SpinHP: TJvDBSpinEdit;
    SpinSP: TJvDBSpinEdit;
    SpinGP1: TJvDBSpinEdit;
    SpinGP2: TJvDBSpinEdit;
    SpinEnemy: TJvDBSpinEdit;
    SpinHp2: TJvDBSpinEdit;
    SpinSP2: TJvDBSpinEdit;
    SpinGP12: TJvDBSpinEdit;
    SpinGP22: TJvDBSpinEdit;
    SpinEnemy2: TJvDBSpinEdit;
    SpinSpecialDuration: TJvDBSpinEdit;
    SpinPasted: TJvDBSpinEdit;
    SpinChars: TJvDBSpinEdit;
    SpinHistory: TJvDBSpinEdit;
    SpinTabChars: TJvDBSpinEdit;
    SpinTabBuffer: TJvDBSpinEdit;
    SpinMaxEvents: TJvDBSpinEdit;
    GridRetain: TSMDBGrid;
    GridReverse: TSMDBGrid;
    dsOptions: TDataSource;
    DSOptions3: TDataSource;
    DSGlobals: TDataSource;
    DSOptions2: TDataSource;
    procedure BtnCancelClick(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
    procedure BtnOverClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BtnClearClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpinHPExit(Sender: TObject);
    procedure SpinHp2Exit(Sender: TObject);
    procedure SpinSPExit(Sender: TObject);
    procedure SpinSP2Exit(Sender: TObject);
    procedure SpinGP1Exit(Sender: TObject);
    procedure SpinGP12Exit(Sender: TObject);
    procedure SpinGP2Exit(Sender: TObject);
    procedure SpinGP22Exit(Sender: TObject);
    procedure SpinEnemyExit(Sender: TObject);
    procedure SpinEnemy2Exit(Sender: TObject);
    procedure BtnColorTypedClick(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure BtnHelpClick(Sender: TObject);
    procedure BtnSetSoundClick(Sender: TObject);
    procedure BtnPlaySoundClick(Sender: TObject);
    procedure EditRetainKeyPress(Sender: TObject; var Key: Char);
    procedure BtnDeleteClick(Sender: TObject);
    procedure BtnAddClick(Sender: TObject);
    procedure RetainCheckSpaceKeyPress(Sender: TObject; var Key: Char);
    procedure DSRetainDataChange(Sender: TObject; Field: TField);
    procedure CheckRetainAllClick(Sender: TObject);
    procedure EditRCommandKeyPress(Sender: TObject; var Key: Char);
    procedure EditRReverseKeyPress(Sender: TObject; var Key: Char);
    procedure CheckDuplicateKeyPress(Sender: TObject; var Key: Char);
    procedure BtnRDeleteClick(Sender: TObject);
    procedure DSReverseDataChange(Sender: TObject; Field: TField);
    procedure BtnRAddClick(Sender: TObject);
    procedure BtnClearBeepClick(Sender: TObject);
    procedure SpinMaxEventsExit(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure SpinIHExit(Sender: TObject);
    procedure SpinHistoryChange(Sender: TObject);
    procedure SpinScrollChange(Sender: TObject);
    procedure SpinLinewrapChange(Sender: TObject);
  private
    { Private declarations }
    procedure LoadOptions;
    procedure SaveOptions;
    procedure UpdateRetain;
  public
    { Public declarations }
    fcolors: array [0..13] of integer;
    bcolors: array [0..13] of integer;
  end;

var
  FormOptions: TFormOptions;
  bypass, rbypass, editing: boolean;
  oldscrollback: integer;

implementation

uses Database, Main, DBClient;

{$R *.DFM}

procedure TFormOptions.FormCreate(Sender: TObject);
begin
  bypass:=false;
  rbypass:=false;
  editing:=false;
  oldscrollback:=0;
  while TabOptions.activepage <> PageMessages do TabOptions.selectnextpage(true);
end;

procedure TFormOptions.BtnCancelClick(Sender: TObject);
begin
  close;
end;

procedure TFormOptions.BtnOKClick(Sender: TObject);
begin
  if (trunc(SpinScroll.value) <> oldscrollback) and (trunc(SpinScroll.value) > 10000) then begin
    TabOptions.activepage:=PageMessages;
    SpinScroll.setfocus;
    if messagedlg('A huge scrollback buffer could affect performance.  Continue?',
      mtconfirmation,[mbyes,mbcancel],0) = mrcancel then exit;
    messagedlg('Ok, but if you notice slowdowns, remember to come back and lower it a bit',
      mtinformation,[mbok],0);
  end;
  if EditActivator.text = EditQuickchar.text then begin
    messagedlg('The Activator and Quickchar Insertion characters must be different',
      mtinformation,[mbok],0);
      TabOptions.activepage:=PageText;
      EditQuickchar.setfocus;
    exit;
  end;
  SaveOptions;
  close;
end;

procedure TFormOptions.BtnOverClick(Sender: TObject);
begin
  case (sender as TBitBtn).tag of
    101: DialogColor.color:=cl1.brush.color;
    102: DialogColor.color:=cl2.brush.color;
    103: DialogColor.color:=cl3.brush.color;
    104: DialogColor.color:=cl4.brush.color;
    105: DialogColor.color:=cl5.brush.color;
    201: DialogColor.color:=cm1.brush.color;
    202: DialogColor.color:=cm2.brush.color;
    203: DialogColor.color:=cm3.brush.color;
    204: DialogColor.color:=cm4.brush.color;
    205: DialogColor.color:=cm5.brush.color;
    301: DialogColor.color:=ch1.brush.color;
    302: DialogColor.color:=ch2.brush.color;
    303: DialogColor.color:=ch3.brush.color;
    304: DialogColor.color:=ch4.brush.color;
    305: DialogColor.color:=ch5.brush.color;
    401: DialogColor.color:=c1001.brush.color;
    402: DialogColor.color:=c1002.brush.color;
    403: DialogColor.color:=c1003.brush.color;
    404: DialogColor.color:=c1004.brush.color;
    405: DialogColor.color:=c1005.brush.color;
    501: DialogColor.color:=co1.brush.color;
    502: DialogColor.color:=co2.brush.color;
    503: DialogColor.color:=co3.brush.color;
    504: DialogColor.color:=co4.brush.color;
    505: DialogColor.color:=co5.brush.color;
    21: DialogColor.color:=Color21.brush.color;
    22: DialogColor.color:=Color22.brush.color;
    666: DialogColor.color:=Color666.brush.color;
    881: DialogColor.color:=ColorPrimary.brush.color;
    882: DialogColor.color:=ColorSecondary.brush.color;
  end;
  if DialogColor.execute = false then exit;
  case (sender as TBitBtn).tag of
    101: cl1.brush.color:=DialogColor.color;
    102: cl2.brush.color:=DialogColor.color;
    103: cl3.brush.color:=DialogColor.color;
    104: cl4.brush.color:=DialogColor.color;
    105: cl5.brush.color:=DialogColor.color;
    201: cm1.brush.color:=DialogColor.color;
    202: cm2.brush.color:=DialogColor.color;
    203: cm3.brush.color:=DialogColor.color;
    204: cm4.brush.color:=DialogColor.color;
    205: cm5.brush.color:=DialogColor.color;
    301: ch1.brush.color:=DialogColor.color;
    302: ch2.brush.color:=DialogColor.color;
    303: ch3.brush.color:=DialogColor.color;
    304: ch4.brush.color:=DialogColor.color;
    305: ch5.brush.color:=DialogColor.color;
    401: c1001.brush.color:=DialogColor.color;
    402: c1002.brush.color:=DialogColor.color;
    403: c1003.brush.color:=DialogColor.color;
    404: c1004.brush.color:=DialogColor.color;
    405: c1005.brush.color:=DialogColor.color;
    501: co1.brush.color:=DialogColor.color;
    502: co2.brush.color:=DialogColor.color;
    503: co3.brush.color:=DialogColor.color;
    504: co4.brush.color:=DialogColor.color;
    505: co5.brush.color:=DialogColor.color;
    21: Color21.brush.color:=DialogColor.color;
    22: Color22.brush.color:=DialogColor.color;
    666: Color666.brush.color:=DialogColor.color;
    881: ColorPrimary.brush.color:=DialogColor.color;
    882: ColorSecondary.brush.color:=DialogColor.color;
  end;
end;

procedure TFormOptions.FormShow(Sender: TObject);
begin
  LoadOptions;
end;

procedure TFormOptions.LoadOptions;
var doreset: boolean;
begin
  with Datawell.TableOptions do begin
//Messages Tab
    oldscrollback:=fieldbyname('Scroll').asinteger;
    Color21.brush.color:=fieldbyname('Color21').asinteger;
    Color22.brush.color:=fieldbyname('Color22').asinteger;
    EditSound.text:=fieldbyname('Beep').asstring;
//Status Bars Tab
    cl1.brush.color:=fieldbyname('Cl1').asinteger;
    cl2.brush.color:=fieldbyname('Cl2').asinteger;
    cl3.brush.color:=fieldbyname('Cl3').asinteger;
    cl4.brush.color:=fieldbyname('Cl4').asinteger;
    cl5.brush.color:=fieldbyname('Cl5').asinteger;
    cm1.brush.color:=fieldbyname('Cm1').asinteger;
    cm2.brush.color:=fieldbyname('Cm2').asinteger;
    cm3.brush.color:=fieldbyname('Cm3').asinteger;
    cm4.brush.color:=fieldbyname('Cm4').asinteger;
    cm5.brush.color:=fieldbyname('Cm5').asinteger;
    ch1.brush.color:=fieldbyname('Ch1').asinteger;
    ch2.brush.color:=fieldbyname('Ch2').asinteger;
    ch3.brush.color:=fieldbyname('Ch3').asinteger;
    ch4.brush.color:=fieldbyname('Ch4').asinteger;
    ch5.brush.color:=fieldbyname('Ch5').asinteger;
    c1001.brush.color:=fieldbyname('C1001').asinteger;
    c1002.brush.color:=fieldbyname('C1002').asinteger;
    c1003.brush.color:=fieldbyname('C1003').asinteger;
    c1004.brush.color:=fieldbyname('C1004').asinteger;
    c1005.brush.color:=fieldbyname('C1005').asinteger;
    co1.brush.color:=fieldbyname('Co1').asinteger;
    co2.brush.color:=fieldbyname('Co2').asinteger;
    co3.brush.color:=fieldbyname('Co3').asinteger;
    co4.brush.color:=fieldbyname('Co4').asinteger;
    co5.brush.color:=fieldbyname('Co5').asinteger;
//Text Options Tab
    CheckTyped.checked:=fieldbyname('Typed').asboolean;
    FColors[0]:=fieldbyname('FColorTyped').asinteger;
      ColorTyped.font.color:=Datawell.FigureColor(FColors[0]);
    BColors[0]:=fieldbyname('BColorTyped').asinteger;
      ColorTyped.color:=Datawell.FigureColor(BColors[0]);
    CheckNTyped.checked:=fieldbyname('NTyped').asboolean;
    CheckDTyped.checked:=fieldbyname('DTyped').asboolean;
    CheckAutotyper.checked:=fieldbyname('Autotyper').asboolean;
    FColors[1]:=fieldbyname('FColorAutotyper').asinteger;
      ColorAutotyper.font.color:=Datawell.FigureColor(FColors[1]);
    BColors[1]:=fieldbyname('BColorAutotyper').asinteger;
      ColorAutotyper.color:=Datawell.FigureColor(BColors[1]);
    CheckNAutotyper.checked:=fieldbyname('NAutotyper').asboolean;
    CheckDAutotyper.checked:=fieldbyname('DAutotyper').asboolean;
    CheckAliases.checked:=fieldbyname('Aliases').asboolean;
    FColors[2]:=fieldbyname('FColorAliases').asinteger;
      ColorAliases.font.color:=Datawell.FigureColor(FColors[2]);
    BColors[2]:=fieldbyname('BColorAliases').asinteger;
      ColorAliases.color:=Datawell.FigureColor(BColors[2]);
    CheckNAliases.checked:=fieldbyname('NAliases').asboolean;
    CheckDAliases.checked:=fieldbyname('DAliases').asboolean;
    CheckMacros.checked:=fieldbyname('Macros').asboolean;
    FColors[3]:=fieldbyname('FColorMacros').asinteger;
      ColorMacros.font.color:=Datawell.FigureColor(FColors[3]);
    BColors[3]:=fieldbyname('BColorMacros').asinteger;
      ColorMacros.color:=Datawell.FigureColor(BColors[3]);
    CheckNMacros.checked:=fieldbyname('NMacros').asboolean;
    CheckDMacros.checked:=fieldbyname('DMacros').asboolean;
    CheckEvents.checked:=fieldbyname('Events').asboolean;
    FColors[4]:=fieldbyname('FColorEvents').asinteger;
      ColorEvents.font.color:=Datawell.FigureColor(FColors[4]);
    BColors[4]:=fieldbyname('BColorEvents').asinteger;
      ColorEvents.color:=Datawell.FigureColor(BColors[4]);
    CheckNEvents.checked:=fieldbyname('NEvents').asboolean;
    CheckDEvents.checked:=fieldbyname('DEvents').asboolean;
    CheckPasted.checked:=fieldbyname('Pasted').asboolean;
    FColors[5]:=fieldbyname('FColorPasted').asinteger;
      ColorPasted.font.color:=Datawell.FigureColor(FColors[5]);
    BColors[5]:=fieldbyname('BColorPasted').asinteger;
      ColorPasted.color:=Datawell.FigureColor(BColors[5]);
    CheckNPasted.checked:=fieldbyname('NPasted').asboolean;
    CheckDPasted.checked:=fieldbyname('DPasted').asboolean;
    CheckEQuickchars.checked:=fieldbyname('EQuickchars').asboolean;
    FColors[8]:=fieldbyname('FColorQuickchars').asinteger;
      ColorQuickchars.font.color:=Datawell.FigureColor(FColors[8]);
    BColors[8]:=fieldbyname('BColorQuickchars').asinteger;
      ColorQuickchars.color:=Datawell.FigureColor(BColors[8]);
    CheckNQuickchars.checked:=fieldbyname('NQuickchars').asboolean;
    CheckDQuickchars.checked:=fieldbyname('DQuickchars').asboolean;
    CheckETicker.checked:=fieldbyname('ETicker').asboolean;
    FColors[10]:=fieldbyname('FColorTicker').asinteger;
      ColorTicker.font.color:=Datawell.FigureColor(FColors[10]);
    BColors[10]:=fieldbyname('BColorTicker').asinteger;
      ColorTicker.color:=Datawell.FigureColor(BColors[10]);
    CheckNTicker.checked:=fieldbyname('NTicker').asboolean;
    CheckDTicker.checked:=fieldbyname('DTicker').asboolean;
    CheckEParsed.checked:=fieldbyname('EParsed').asboolean;
    FColors[11]:=fieldbyname('FColorParsed').asinteger;
      ColorParsed.font.color:=Datawell.FigureColor(FColors[11]);
    BColors[11]:=fieldbyname('BColorParsed').asinteger;
      ColorParsed.color:=Datawell.FigureColor(BColors[11]);
    CheckNParsed.checked:=fieldbyname('NParsed').asboolean;
    CheckDParsed.checked:=fieldbyname('DParsed').asboolean;
    FColors[6]:=fieldbyname('FColorSystem').asinteger;
      ColorSystem.font.color:=Datawell.FigureColor(FColors[6]);
    BColors[6]:=fieldbyname('BColorSystem').asinteger;
      ColorSystem.color:=Datawell.FigureColor(BColors[6]);
    FColors[7]:=fieldbyname('FColorSelected').asinteger;
      ColorSelected.font.color:=Datawell.FigureColor(FColors[7]);
    BColors[7]:=fieldbyname('BColorSelected').asinteger;
      ColorSelected.color:=Datawell.FigureColor(BColors[7]);
    MaskGP1.text:=fieldbyname('GP1Mask').asstring;
    MaskGP2.text:=fieldbyname('GP2Mask').asstring;
//Miscellaneous Tab
    EditActivator.itemindex:=EditActivator.items.indexof(fieldbyname('Activator').asstring);
    EditQuickchar.itemindex:=EditQuickchar.items.indexof(fieldbyname('Quickchar').asstring);
    CheckSounds.checked:=fieldbyname('Sounds').asboolean;
    CheckAutocopy.checked:=fieldbyname('Autocopy').asboolean;
    CheckPageup.checked:=fieldbyname('Pageup').asboolean;
    CheckFeed.checked:=fieldbyname('FeedScrollback').asboolean;
    CheckLabels.checked:=fieldbyname('ScrollbackLabels').asboolean;
    CheckClearSending.checked:=fieldbyname('ClearSending').asboolean;
    CheckEscape.checked:=fieldbyname('FEscape').asboolean;
    CheckAltF4.checked:=fieldbyname('AltF4ToClose').asboolean;
    CheckMenu.checked:=fieldbyname('Menu').asboolean;
    CheckTab.checked:=fieldbyname('Tab').asboolean;
    CheckHighlightKeyhistory.checked:=fieldbyname('HighlightKeyhistory').asboolean;
//Command Line Tab
    CheckRetainAll.checked:=fieldbyname('RetainAll').asboolean;
    CheckRetain.checked:=fieldbyname('FRetain').asboolean;
//FTP Emulation Tab
    CheckLocalDir.checked:=fieldbyname('UseLocalDir').asboolean;
    doreset:=false;
    try DirectoryLocal.directory:=fieldbyname('LocalDir').asstring;
      except on EInOutError do doreset:=true;
    end;
    if doreset then begin
      try DirectoryLocal.directory:=datawell.exedir;
        except on EInOutError do doreset:=true;
      end;
    end;
    if doreset then begin
      try DirectoryLocal.directory:='c:';
        except on EInOutError do end;
    end;
    CheckOverwriteLocal.checked:=fieldbyname('OverwriteLocalDir').asboolean;
  end;
//Global Options Tab
  with Datawell.TableGlobals do begin
    CheckWarnings.checked:=fieldbyname('ShowWarnings').asboolean;
    CheckBackup.checked:=fieldbyname('L10').asboolean;
    CheckPersistentCLH.checked:=fieldbyname('L3').asboolean;
    CheckProfanity.checked:=fieldbyname('L12').asboolean;
    CheckReconnect.checked:=fieldbyname('L11').asboolean;
  end;
//Options2
  with Datawell.TableOptions2 do begin
    CheckBTyped.checked:=fieldbyname('BTyped').asboolean;
    CheckBAutotyped.checked:=fieldbyname('BAutotyped').asboolean;
    CheckBAliases.checked:=fieldbyname('BAliases').asboolean;
    CheckBPasted.checked:=fieldbyname('BPasted').asboolean;
    CheckBMacros.checked:=fieldbyname('BMacros').asboolean;
    CheckBEvents.checked:=fieldbyname('BEvents').asboolean;
    CheckBQuickchars.checked:=fieldbyname('BQuickchars').asboolean;
    CheckBTicker.checked:=fieldbyname('BTicker').asboolean;
    CheckBParsed.checked:=fieldbyname('BParsed').asboolean;
    CheckTruncate.checked:=fieldbyname('Truncate').asboolean;
    CheckVTyped.checked:=fieldbyname('VTyped').asboolean;
    CheckVAutotyped.checked:=fieldbyname('VAutotyped').asboolean;
    CheckVAliases.checked:=fieldbyname('VAliases').asboolean;
    CheckVPasted.checked:=fieldbyname('VPasted').asboolean;
    CheckVMacros.checked:=fieldbyname('VMacros').asboolean;
    CheckVEvents.checked:=fieldbyname('VEvents').asboolean;
    CheckVQuickchars.checked:=fieldbyname('VQuickchars').asboolean;
    CheckVTicker.checked:=fieldbyname('VTicker').asboolean;
    CheckVParsed.checked:=fieldbyname('VParsed').asboolean;
    CheckFTyped.checked:=fieldbyname('FTyped').asboolean;
    CheckFAutotyped.checked:=fieldbyname('FAutotyped').asboolean;
    CheckFAliases.checked:=fieldbyname('FAliases').asboolean;
    CheckFPasted.checked:=fieldbyname('FPasted').asboolean;
    CheckFMacros.checked:=fieldbyname('FMacros').asboolean;
    CheckFEvents.checked:=fieldbyname('FEvents').asboolean;
    CheckFQuickchars.checked:=fieldbyname('FQuickchars').asboolean;
    CheckFTicker.checked:=fieldbyname('FTicker').asboolean;
    CheckFParsed.checked:=fieldbyname('FParsed').asboolean;
    CheckDisableAliasLED.checked:=fieldbyname('DisableAliasLED').asboolean;
    CheckAutoExpand.checked:=fieldbyname('AutoExpand').asboolean;
    CheckFullFlash.checked:=fieldbyname('FullFlash').asboolean;
    CheckDelayUpload.checked:=fieldbyname('DelayUpload').asboolean;
    CheckPCorrect.checked:=fieldbyname('PCorrect').asboolean;
    CheckEnableHyperlinks.checked:=fieldbyname('EnableHyperlinks').asboolean;
    FColors[12]:=fieldbyname('HyperlinkFGColor').asinteger;
      ColorHyperlink.font.color:=Datawell.FigureColor(FColors[12]);
    BColors[12]:=fieldbyname('HyperlinkBGColor').asinteger;
      ColorHyperlink.color:=Datawell.FigureColor(BColors[12]);
    EditHPMask.text:=fieldbyname('HPMask').asstring;
    EditSPMask.text:=fieldbyname('SPMask').asstring;
    CheckAutoShowImagery.checked:=fieldbyname('AutoShowImagery').asboolean;
  end;
//Options3
  with Datawell.TableOptions3 do begin
    EditSecondaryPrompt.text:=fieldbyname('S1').asstring;
    if fieldbyname('S2').asstring = '[30' then ColorGrid.foregroundindex:=0
    else if fieldbyname('S2').asstring = '[31' then ColorGrid.foregroundindex:=1
    else if fieldbyname('S2').asstring = '[32' then ColorGrid.foregroundindex:=2
    else if fieldbyname('S2').asstring = '[33' then ColorGrid.foregroundindex:=3
    else if fieldbyname('S2').asstring = '[34' then ColorGrid.foregroundindex:=4
    else if fieldbyname('S2').asstring = '[35' then ColorGrid.foregroundindex:=5
    else if fieldbyname('S2').asstring = '[36' then ColorGrid.foregroundindex:=6
    else if fieldbyname('S2').asstring = '[37' then ColorGrid.foregroundindex:=7
    else if fieldbyname('S2').asstring = '[30;1' then ColorGrid.foregroundindex:=8
    else if fieldbyname('S2').asstring = '[31;1' then ColorGrid.foregroundindex:=9
    else if fieldbyname('S2').asstring = '[32;1' then ColorGrid.foregroundindex:=10
    else if fieldbyname('S2').asstring = '[33;1' then ColorGrid.foregroundindex:=11
    else if fieldbyname('S2').asstring = '[34;1' then ColorGrid.foregroundindex:=12
    else if fieldbyname('S2').asstring = '[35;1' then ColorGrid.foregroundindex:=13
    else if fieldbyname('S2').asstring = '[36;1' then ColorGrid.foregroundindex:=14
    else if fieldbyname('S2').asstring = '[37;1' then ColorGrid.foregroundindex:=15;
    CheckEnableChat.checked:=fieldbyname('L1').asboolean;
    CheckEnableTell.checked:=fieldbyname('L17').asboolean;
    CheckPanicLock.checked:=fieldbyname('L3').asboolean;
    CheckPanicBeep.checked:=fieldbyname('L51').asboolean;
    CheckWarnBreak.checked:=fieldbyname('L52').asboolean;
    CheckESprint.checked:=fieldbyname('L6').asboolean;
    CheckNSprint.checked:=fieldbyname('L7').asboolean;
    CheckVSprint.checked:=fieldbyname('L8').asboolean;
    CheckFSprint.checked:=fieldbyname('L9').asboolean;
    CheckBSprint.checked:=fieldbyname('L11').asboolean;
    CheckDSprint.checked:=fieldbyname('L12').asboolean;
    CheckPureLine.checked:=fieldbyname('L14').asboolean;
    CheckForced.checked:=fieldbyname('L54').asboolean;
    Well1.text:=fieldbyname('S56').asstring;
    Well2.text:=fieldbyname('S57').asstring;
    Well3.text:=fieldbyname('S58').asstring;
    Well4.text:=fieldbyname('S59').asstring;
    Well5.text:=fieldbyname('S60').asstring;
    CheckAutoExpandImagery.checked:=fieldbyname('L23').asboolean;
    Color666.brush.color:=fieldbyname('I19').asinteger;
    CheckEnableRemote.checked:=fieldbyname('L24').asboolean;
    CheckHP.checked:=fieldbyname('L25').asboolean;
    CheckSP.checked:=fieldbyname('L26').asboolean;
    CheckGP1.checked:=fieldbyname('L27').asboolean;
    CheckGP2.checked:=fieldbyname('L28').asboolean;
    CheckEnemy.checked:=fieldbyname('L29').asboolean;
    CheckAutoDownload.checked:=fieldbyname('L30').asboolean;
    CheckMaskPassword.checked:=fieldbyname('L32').asboolean;
    CheckAutoPlay.checked:=fieldbyname('L34').asboolean;
    CheckNotify.checked:=fieldbyname('L35').asboolean;
    CheckShowText.checked:=fieldbyname('L42').asboolean;
    CheckStatus.checked:=fieldbyname('L43').asboolean;
    CheckScrollExit.checked:=fieldbyname('L44').asboolean;
    CheckAutoKillSecondary.checked:=fieldbyname('L45').asboolean;
    CheckIdle.checked:=fieldbyname('L48').asboolean;
    Check2Italics.checked:=fieldbyname('L49').asboolean;
    CheckSecondaryColor.checked:=fieldbyname('L50').asboolean;
    CheckActiveKeyhistory.checked:=fieldbyname('L53').asboolean;
    ColorPrimary.brush.color:=fieldbyname('I26').asinteger;
    ColorSecondary.brush.color:=fieldbyname('I27').asinteger;
    FColors[13]:=fieldbyname('I5').asinteger;
      ColorSprint.font.color:=Datawell.FigureColor(FColors[13]);
    BColors[13]:=fieldbyname('I6').asinteger;
      ColorSprint.color:=Datawell.FigureColor(BColors[13]);
    CheckTabCompletion.checked:=fieldbyname('L58').asboolean;
    CheckTabLowercase.checked:=fieldbyname('L59').asboolean;
    CheckCopyFilename.checked:=fieldbyname('L61').asboolean;
    EditTab1.text:=fieldbyname('S10').asstring;
    EditTab2.text:=fieldbyname('S11').asstring;
    EditTab3.text:=fieldbyname('S12').asstring;
    EditTab4.text:=fieldbyname('S13').asstring;
    EditTab5.text:=fieldbyname('S14').asstring;
    EditTab6.text:=fieldbyname('S15').asstring;
    EditTab7.text:=fieldbyname('S16').asstring;
    EditTab8.text:=fieldbyname('S17').asstring;
  end;
  UpdateRetain;
end;

procedure TFormOptions.SaveOptions;
begin
  with Datawell.TableOptions do begin
//Messages Tab
    edit;
    fieldbyname('Color21').asinteger:=Color21.brush.color;
    fieldbyname('Color22').asinteger:=Color22.brush.color;
    fieldbyname('Beep').asstring:=EditSound.text;
//Status Bars Tab
    fieldbyname('Cl1').asinteger:=cl1.brush.color;
    fieldbyname('Cl2').asinteger:=cl2.brush.color;
    fieldbyname('Cl3').asinteger:=cl3.brush.color;
    fieldbyname('Cl4').asinteger:=cl4.brush.color;
    fieldbyname('Cl5').asinteger:=cl5.brush.color;
    fieldbyname('Cm1').asinteger:=cm1.brush.color;
    fieldbyname('Cm2').asinteger:=cm2.brush.color;
    fieldbyname('Cm3').asinteger:=cm3.brush.color;
    fieldbyname('Cm4').asinteger:=cm4.brush.color;
    fieldbyname('Cm5').asinteger:=cm5.brush.color;
    fieldbyname('Ch1').asinteger:=ch1.brush.color;
    fieldbyname('Ch2').asinteger:=ch2.brush.color;
    fieldbyname('Ch3').asinteger:=ch3.brush.color;
    fieldbyname('Ch4').asinteger:=ch4.brush.color;
    fieldbyname('Ch5').asinteger:=ch5.brush.color;
    fieldbyname('C1001').asinteger:=c1001.brush.color;
    fieldbyname('C1002').asinteger:=c1002.brush.color;
    fieldbyname('C1003').asinteger:=c1003.brush.color;
    fieldbyname('C1004').asinteger:=c1004.brush.color;
    fieldbyname('C1005').asinteger:=c1005.brush.color;
    fieldbyname('Co1').asinteger:=co1.brush.color;
    fieldbyname('Co2').asinteger:=co2.brush.color;
    fieldbyname('Co3').asinteger:=co3.brush.color;
    fieldbyname('Co4').asinteger:=co4.brush.color;
    fieldbyname('Co5').asinteger:=co5.brush.color;
//Text Options Tab
    fieldbyname('Typed').asboolean:=CheckTyped.checked;
    fieldbyname('FColorTyped').asinteger:=FColors[0];
    fieldbyname('BColorTyped').asinteger:=BColors[0];
    fieldbyname('NTyped').asboolean:=CheckNTyped.checked;
    fieldbyname('DTyped').asboolean:=CheckDTyped.checked;
    fieldbyname('Autotyper').asboolean:=CheckAutotyper.checked;
    fieldbyname('FColorAutotyper').asinteger:=FColors[1];
    fieldbyname('BColorAutotyper').asinteger:=BColors[1];
    fieldbyname('NAutotyper').asboolean:=CheckNAutotyper.checked;
    fieldbyname('DAutotyper').asboolean:=CheckDAutotyper.checked;
    fieldbyname('Aliases').asboolean:=CheckAliases.checked;
    fieldbyname('FColorAliases').asinteger:=FColors[2];
    fieldbyname('BColorAliases').asinteger:=BColors[2];
    fieldbyname('NAliases').asboolean:=CheckNAliases.checked;
    fieldbyname('DAliases').asboolean:=CheckDAliases.checked;
    fieldbyname('Macros').asboolean:=CheckMacros.checked;
    fieldbyname('FColorMacros').asinteger:=FColors[3];
    fieldbyname('BColorMacros').asinteger:=BColors[3];
    fieldbyname('NMacros').asboolean:=CheckNMacros.checked;
    fieldbyname('DMacros').asboolean:=CheckDMacros.checked;
    fieldbyname('Events').asboolean:=CheckEvents.checked;
    fieldbyname('FColorEvents').asinteger:=FColors[4];
    fieldbyname('BColorEvents').asinteger:=BColors[4];
    fieldbyname('NEvents').asboolean:=CheckNEvents.checked;
    fieldbyname('DEvents').asboolean:=CheckDEvents.checked;
    fieldbyname('Pasted').asboolean:=CheckPasted.checked;
    fieldbyname('FColorPasted').asinteger:=FColors[5];
    fieldbyname('BColorPasted').asinteger:=BColors[5];
    fieldbyname('NPasted').asboolean:=CheckNPasted.checked;
    fieldbyname('DPasted').asboolean:=CheckDPasted.checked;
    fieldbyname('EQuickchars').asboolean:=CheckEQuickchars.checked;
    fieldbyname('FColorQuickchars').asinteger:=FColors[8];
    fieldbyname('BColorQuickchars').asinteger:=BColors[8];
    fieldbyname('NQuickchars').asboolean:=CheckNQuickchars.checked;
    fieldbyname('DQuickchars').asboolean:=CheckDQuickchars.checked;
    fieldbyname('ETicker').asboolean:=CheckETicker.checked;
    fieldbyname('FColorTicker').asinteger:=FColors[10];
    fieldbyname('BColorTicker').asinteger:=BColors[10];
    fieldbyname('NTicker').asboolean:=CheckNTicker.checked;
    fieldbyname('DTicker').asboolean:=CheckDTicker.checked;
    fieldbyname('EParsed').asboolean:=CheckEParsed.checked;
    fieldbyname('FColorParsed').asinteger:=FColors[11];
    fieldbyname('BColorParsed').asinteger:=BColors[11];
    fieldbyname('NParsed').asboolean:=CheckNParsed.checked;
    fieldbyname('DParsed').asboolean:=CheckDParsed.checked;
    fieldbyname('FColorSelected').asinteger:=FColors[7];
    fieldbyname('BColorSelected').asinteger:=BColors[7];
    fieldbyname('FColorSystem').asinteger:=FColors[6];
    fieldbyname('BColorSystem').asinteger:=BColors[6];
    fieldbyname('GP1Mask').asstring:=MaskGP1.text;
    fieldbyname('GP2Mask').asstring:=MaskGP2.text;
//Miscellaneous Tab
    fieldbyname('Activator').asstring:=EditActivator.text;
    fieldbyname('Quickchar').asstring:=EditQuickchar.text;
    fieldbyname('Sounds').asboolean:=CheckSounds.checked;
    fieldbyname('Autocopy').asboolean:=CheckAutocopy.checked;
    fieldbyname('Pageup').asboolean:=CheckPageup.checked;
    fieldbyname('FeedScrollback').asboolean:=CheckFeed.checked;
    fieldbyname('ScrollbackLabels').asboolean:=CheckLabels.checked;
    fieldbyname('ClearSending').asboolean:=CheckClearSending.checked;
    fieldbyname('FEscape').asboolean:=CheckEscape.checked;
    fieldbyname('AltF4ToClose').asboolean:=CheckAltF4.checked;
    fieldbyname('Menu').asboolean:=CheckMenu.checked;
    fieldbyname('Tab').asboolean:=CheckTab.checked;
    fieldbyname('HighlightKeyhistory').asboolean:=CheckHighlightKeyhistory.checked;
//Command Line Tab
    fieldbyname('RetainAll').asboolean:=CheckRetainAll.checked;
    fieldbyname('FRetain').asboolean:=CheckRetain.checked;
//FTP Emulation Tab
    fieldbyname('UseLocalDir').asboolean:=CheckLocalDir.checked;
    fieldbyname('LocalDir').asstring:=DirectoryLocal.directory;
    fieldbyname('OverwriteLocalDir').asboolean:=CheckOverwriteLocal.checked;
    post;
  end;
//Global Options Tab
  with Datawell.TableGlobals do begin
    edit;
    fieldbyname('ShowWarnings').asboolean:=CheckWarnings.checked;
    fieldbyname('L10').asboolean:=CheckBackup.checked;
    fieldbyname('L3').asboolean:=CheckPersistentCLH.checked;
    fieldbyname('L12').asboolean:=CheckProfanity.checked;
    fieldbyname('L11').asboolean:=CheckReconnect.checked;
    post;
  end;
//Options2
  with Datawell.TableOptions2 do begin
    edit;
    fieldbyname('BTyped').asboolean:=CheckBTyped.checked;
    fieldbyname('BAutotyped').asboolean:=CheckBAutotyped.checked;
    fieldbyname('BAliases').asboolean:=CheckBAliases.checked;
    fieldbyname('BPasted').asboolean:=CheckBPasted.checked;
    fieldbyname('BMacros').asboolean:=CheckBMacros.checked;
    fieldbyname('BEvents').asboolean:=CheckBEvents.checked;
    fieldbyname('BQuickchars').asboolean:=CheckBQuickchars.checked;
    fieldbyname('BTicker').asboolean:=CheckBTicker.checked;
    fieldbyname('BParsed').asboolean:=CheckBParsed.checked;
    fieldbyname('Truncate').asboolean:=CheckTruncate.checked;
    fieldbyname('VTyped').asboolean:=CheckVTyped.checked;
    fieldbyname('VAutotyped').asboolean:=CheckVAutotyped.checked;
    fieldbyname('VAliases').asboolean:=CheckVAliases.checked;
    fieldbyname('VPasted').asboolean:=CheckVPasted.checked;
    fieldbyname('VMacros').asboolean:=CheckVMacros.checked;
    fieldbyname('VEvents').asboolean:=CheckVEvents.checked;
    fieldbyname('VQuickchars').asboolean:=CheckVQuickchars.checked;
    fieldbyname('VTicker').asboolean:=CheckVTicker.checked;
    fieldbyname('VParsed').asboolean:=CheckVParsed.checked;
    fieldbyname('AutoShowImagery').asboolean:=CheckAutoShowImagery.checked;
    fieldbyname('EnableHyperlinks').asboolean:=CheckEnableHyperlinks.checked;
    fieldbyname('HyperlinkFGColor').asinteger:=FColors[12];
    fieldbyname('HyperlinkBGColor').asinteger:=BColors[12];
    fieldbyname('FTyped').asboolean:=CheckFTyped.checked;
    fieldbyname('FAutotyped').asboolean:=CheckFAutotyped.checked;
    fieldbyname('FAliases').asboolean:=CheckFAliases.checked;
    fieldbyname('FPasted').asboolean:=CheckFPasted.checked;
    fieldbyname('FMacros').asboolean:=CheckFMacros.checked;
    fieldbyname('FEvents').asboolean:=CheckFEvents.checked;
    fieldbyname('FQuickchars').asboolean:=CheckFQuickchars.checked;
    fieldbyname('FTicker').asboolean:=CheckFTicker.checked;
    fieldbyname('FParsed').asboolean:=CheckFParsed.checked;
    fieldbyname('DisableAliasLED').asboolean:=CheckDisableAliasLED.checked;
    fieldbyname('AutoExpand').asboolean:=CheckAutoExpand.checked;
    fieldbyname('FullFlash').asboolean:=CheckFullFlash.checked;
    fieldbyname('HPMask').asstring:=EditHPMask.text;
    fieldbyname('SPMask').asstring:=EditSPMask.text;
    fieldbyname('DelayUpload').asboolean:=CheckDelayUpload.checked;
    fieldbyname('PCorrect').asboolean:=CheckPCorrect.checked;
    post;
  end;
//Options3
  with Datawell.TableOptions3 do begin
    edit;
    fieldbyname('S1').asstring:=EditSecondaryPrompt.text;
    case ColorGrid.foregroundindex of
      0: fieldbyname('S2').asstring:='[30';
      1: fieldbyname('S2').asstring:='[31';
      2: fieldbyname('S2').asstring:='[32';
      3: fieldbyname('S2').asstring:='[33';
      4: fieldbyname('S2').asstring:='[34';
      5: fieldbyname('S2').asstring:='[35';
      6: fieldbyname('S2').asstring:='[36';
      7: fieldbyname('S2').asstring:='[37';
      8: fieldbyname('S2').asstring:='[30;1';
      9: fieldbyname('S2').asstring:='[31;1';
     10: fieldbyname('S2').asstring:='[32;1';
     11: fieldbyname('S2').asstring:='[33;1';
     12: fieldbyname('S2').asstring:='[34;1';
     13: fieldbyname('S2').asstring:='[35;1';
     14: fieldbyname('S2').asstring:='[36;1';
     15: fieldbyname('S2').asstring:='[37;1';
    end;
    fieldbyname('L1').asboolean:=CheckEnableChat.checked;
    fieldbyname('L17').asboolean:=CheckEnableTell.checked;
    fieldbyname('L3').asboolean:=CheckPanicLock.checked;
    fieldbyname('L51').asboolean:=CheckPanicBeep.checked;
    fieldbyname('L52').asboolean:=CheckWarnBreak.checked;
    fieldbyname('L6').asboolean:=CheckESprint.checked;
    fieldbyname('L7').asboolean:=CheckNSprint.checked;
    fieldbyname('L8').asboolean:=CheckVSprint.checked;
    fieldbyname('L9').asboolean:=CheckFSprint.checked;
    fieldbyname('L11').asboolean:=CheckBSprint.checked;
    fieldbyname('L12').asboolean:=CheckDSprint.checked;
    fieldbyname('I5').asinteger:=FColors[13];
    fieldbyname('I6').asinteger:=BColors[13];
    fieldbyname('L14').asboolean:=CheckPureLine.checked;
    fieldbyname('L54').asboolean:=CheckForced.checked;
    fieldbyname('S56').asstring:=Well1.text;
    fieldbyname('S57').asstring:=Well2.text;
    fieldbyname('S58').asstring:=Well3.text;
    fieldbyname('S59').asstring:=Well4.text;
    fieldbyname('S60').asstring:=Well5.text;
    fieldbyname('L23').asboolean:=CheckAutoExpandImagery.checked;
    fieldbyname('I19').asinteger:=Color666.brush.color;
    fieldbyname('L24').asboolean:=CheckEnableRemote.checked;
    fieldbyname('L25').asboolean:=CheckHP.checked;
    fieldbyname('L26').asboolean:=CheckSP.checked;
    fieldbyname('L27').asboolean:=CheckGP1.checked;
    fieldbyname('L28').asboolean:=CheckGP2.checked;
    fieldbyname('L29').asboolean:=CheckEnemy.checked;
    fieldbyname('L30').asboolean:=CheckAutoDownload.checked;
    fieldbyname('L32').asboolean:=CheckMaskPassword.checked;
    fieldbyname('L34').asboolean:=CheckAutoPlay.checked;
    fieldbyname('L35').asboolean:=CheckNotify.checked;
    fieldbyname('L42').asboolean:=CheckShowText.checked;
    fieldbyname('L43').asboolean:=CheckStatus.checked;
    fieldbyname('L44').asboolean:=CheckScrollExit.checked;
    fieldbyname('L45').asboolean:=CheckAutoKillSecondary.checked;
    fieldbyname('L48').asboolean:=CheckIdle.checked;
    fieldbyname('L49').asboolean:=Check2Italics.checked;
    fieldbyname('L50').asboolean:=CheckSecondaryColor.checked;
    fieldbyname('L53').asboolean:=CheckActiveKeyhistory.checked;
    fieldbyname('L58').asboolean:=CheckTabCompletion.checked;
    fieldbyname('L59').asboolean:=CheckTabLowercase.checked;
    fieldbyname('L61').asboolean:=CheckCopyFilename.checked;
    fieldbyname('I26').asinteger:=ColorPrimary.brush.color;
    fieldbyname('I27').asinteger:=ColorSecondary.brush.color;
    fieldbyname('S10').asstring:=EditTab1.text;
    fieldbyname('S11').asstring:=EditTab2.text;
    fieldbyname('S12').asstring:=EditTab3.text;
    fieldbyname('S13').asstring:=EditTab4.text;
    fieldbyname('S14').asstring:=EditTab5.text;
    fieldbyname('S15').asstring:=EditTab6.text;
    fieldbyname('S16').asstring:=EditTab7.text;
    fieldbyname('S17').asstring:=EditTab8.text;
    post;
  end;
  Datawell.BuildWell;
end;

procedure TFormOptions.SpinHPExit(Sender: TObject);
begin
  if SpinHP.value < 1 then SpinHP.value:=1;
  if SpinHP.value > SpinHP2.value then SpinHP2.value:=SpinHP.value;
end;

procedure TFormOptions.SpinHp2Exit(Sender: TObject);
begin
  if SpinHP2.value < 1 then SpinHP2.value:=1;
  if SpinHP2.value < SpinHP.value then SpinHP.value:=SpinHP2.value;
end;

procedure TFormOptions.SpinSPExit(Sender: TObject);
begin
  if SpinSP.value < 1 then SpinSP.value:=1;
  if SpinSP.value > SpinSP2.value then SpinSP2.value:=SpinSP.value;
end;

procedure TFormOptions.SpinSP2Exit(Sender: TObject);
begin
  if SpinSP2.value < 1 then SpinSP2.value:=1;
  if SpinSP2.value < SpinSP.value then SpinSP.value:=SpinSP2.value;
end;

procedure TFormOptions.SpinGP1Exit(Sender: TObject);
begin
  if SpinGP1.value < 1 then SpinGP1.value:=1;
  if SpinGP1.value > SpinGP12.value then SpinGP12.value:=SpinGP1.value;
end;

procedure TFormOptions.SpinGP12Exit(Sender: TObject);
begin
  if SpinGP12.value < 1 then SpinGP12.value:=1;
  if SpinGP12.value < SpinGP1.value then SpinGP1.value:=SpinGP12.value;
end;

procedure TFormOptions.SpinGP2Exit(Sender: TObject);
begin
  if SpinGP2.value < 1 then SpinGP2.value:=1;
  if SpinGP2.value > SpinGP22.value then SpinGP22.value:=SpinGP2.value;
end;

procedure TFormOptions.SpinGP22Exit(Sender: TObject);
begin
  if SpinGP22.value < 1 then SpinGP22.value:=1;
  if SpinGP22.value < SpinGP2.value then SpinGP2.value:=SpinGP22.value;
end;

procedure TFormOptions.SpinEnemyExit(Sender: TObject);
begin
  if SpinEnemy.value < 1 then SpinEnemy.value:=1;
  if SpinEnemy.value > SpinEnemy2.value then SpinEnemy2.value:=SpinEnemy.value;
end;

procedure TFormOptions.SpinEnemy2Exit(Sender: TObject);
begin
  if SpinEnemy2.value < 1 then SpinEnemy2.value:=1;
  if SpinEnemy2.value < SpinEnemy.value then SpinEnemy.value:=SpinEnemy2.value;
end;

procedure TFormOptions.BtnColorTypedClick(Sender: TObject);
var
  form: TFormColor;
  fi, bi, i: integer;
begin
  i:=(sender as TComponent).tag;
  form:=TFormColor.create(self);
  form.ColorGrid.foregroundindex:=fcolors[i-1];
  form.ColorGrid.backgroundindex:=bcolors[i-1];
  form.showmodal;
  fi:=form.findex;
  bi:=form.bindex;
  form.free;
  if (fi < 0) or (bi < 0) then exit;
  fcolors[i-1]:=fi;
  bcolors[i-1]:=bi;
  case i of
    1: begin
         ColorTyped.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorTyped.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    2: begin
         ColorAutotyper.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorAutotyper.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    3: begin
         ColorAliases.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorAliases.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    4: begin
         ColorMacros.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorMacros.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    5: begin
         ColorEvents.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorEvents.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    6: begin
         ColorPasted.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorPasted.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    7: begin
         ColorSystem.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorSystem.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    8: begin
         ColorSelected.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorSelected.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    9: begin
         ColorQuickchars.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorQuickchars.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    11: begin
         ColorTicker.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorTicker.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    12: begin
         ColorParsed.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorParsed.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    13: begin
         ColorHyperlink.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorHyperlink.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
    14: begin
         ColorSprint.font.color:=Datawell.FigureColor(fcolors[i-1]);
         ColorSprint.color:=Datawell.FigureColor(bcolors[i-1]);
       end;
  end;
end;

procedure TFormOptions.FormMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  Status.caption:=' '+(sender as TControl).hint;
end;

procedure TFormOptions.BtnHelpClick(Sender: TObject);
begin
  Datawell.Help('program_options');
end;

procedure TFormOptions.BtnSetSoundClick(Sender: TObject);
var
  sound: string;
  form: TFormSounds;
begin
  form:=TFormSounds.create(self);
  if FileExists(EditSound.text) then form.files.filename:=EditSound.text;
  form.showmodal;
  sound:=form.sound;
  form.free;
  if sound = '' then exit;
  EditSound.text:=sound;
end;

procedure TFormOptions.BtnPlaySoundClick(Sender: TObject);
begin
  FormMain.PlaySound(EditSound.text,1,0,0,false);
end;

procedure TFormOptions.EditRetainKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    RetainCheckSpace.setfocus;
    key:=#0;
  end;
end;

procedure TFormOptions.RetainCheckSpaceKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    BtnAdd.click;
    key:=#0;
  end;
end;

procedure TFormOptions.BtnDeleteClick(Sender: TObject);
begin
  bypass:=true;
  if not Datawell.TableRetain.EOF then Datawell.TableRetain.delete;
  bypass:=false;
  EditRetain.selectall;
  EditRetain.setfocus;
end;

procedure TFormOptions.BtnAddClick(Sender: TObject);
var
  didfind: boolean;
  table: TClientDataset;
begin
  didfind:=false;
  if EditRetain.text = '' then begin
    messagedlg('You must enter a command to retain',mtinformation,[mbok],0);
    EditRetain.setfocus;
    exit;
  end;
  EditRetain.text:=Datawell.CutTrailingSpaces(EditRetain.text);
  table:=TClientDataset.create(self);
  with table do begin
    CloneCursor(Datawell.TableRetain, false);
    Filtered := true;
    active:=true;
    first;
    while not EOF do begin
      if fieldbyname('FRetain').asstring = EditRetain.text then begin
        didfind:=true;
        break;
      end;
      next;
    end;
  end;
  table.free;
  if didfind then begin
    messagedlg('That command is already retained',mtinformation,[mbok],0);
    EditRetain.selectall;
    EditRetain.setfocus;
    exit;
  end;
  bypass:=true;
  Datawell.TableRetain.append;
  Datawell.TableRetain.fieldbyname('Master').asinteger:=Datawell.masterinteger;
  Datawell.TableRetain.fieldbyname('FRetain').asstring:=EditRetain.text;
  Datawell.TableRetain.fieldbyname('AddSpace').asboolean:=RetainCheckSpace.checked;
  Datawell.TableRetain.fieldbyname('KeepSelected').asboolean:=false;
  Datawell.TableRetain.post;
  bypass:=false;
  EditRetain.text:='';
  EditRetain.setfocus;
end;

procedure TFormOptions.DSRetainDataChange(Sender: TObject; Field: TField);
begin
  if bypass then exit;
  EditRetain.text:=Datawell.TableRetain.fieldbyname('FRetain').asstring;
  RetainCheckSpace.checked:=Datawell.TableRetain.fieldbyname('AddSpace').asboolean;
end;

procedure TFormOptions.CheckRetainAllClick(Sender: TObject);
begin
  UpdateRetain;
end;

procedure TFormOptions.UpdateRetain;
begin
  if CheckRetainAll.checked then begin
    GridRetain.enabled:=false;
    GridRetain.color:=clsilver;
    CheckRetain.enabled:=false;
    CheckRetain.font.color:=clgray;
    BtnDelete.enabled:=false;
    LabelNew.font.color:=clgray;
    EditRetain.enabled:=false;
    EditRetain.color:=clsilver;
    RetainCheckSpace.enabled:=false;
    RetainCheckSpace.font.color:=clgray;
    BtnAdd.enabled:=false;
  end
  else begin
    GridRetain.enabled:=true;
    GridRetain.color:=clwindow;
    CheckRetain.enabled:=true;
    CheckRetain.font.color:=clblack;
    BtnDelete.enabled:=true;
    LabelNew.font.color:=clblack;
    EditRetain.enabled:=true;
    EditRetain.color:=clwindow;
    RetainCheckSpace.enabled:=true;
    RetainCheckSpace.font.color:=clblack;
    BtnAdd.enabled:=true;
  end;
end;

procedure TFormOptions.EditRCommandKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    EditRReverse.setfocus;
    key:=#0;
  end;
end;

procedure TFormOptions.EditRReverseKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    CheckDuplicate.setfocus;
    key:=#0;
  end;
end;

procedure TFormOptions.CheckDuplicateKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    BtnRAdd.click;
    key:=#0;
  end;
end;

procedure TFormOptions.BtnRDeleteClick(Sender: TObject);
begin
  rbypass:=true;
  if not Datawell.TableReverse.EOF then Datawell.TableReverse.delete;
  rbypass:=false;
  EditRCommand.selectall;
  EditRCommand.setfocus;
end;

procedure TFormOptions.DSReverseDataChange(Sender: TObject; Field: TField);
begin
  if rbypass then exit;
  EditRCommand.text:=Datawell.TableReverse.fieldbyname('Command').asstring;
  EditRReverse.text:=Datawell.TableReverse.fieldbyname('Reverse').asstring;
end;

procedure TFormOptions.BtnRAddClick(Sender: TObject);
var
  didfind, didfind2: boolean;
  table: TClientDataset;
begin
  if EditRCommand.text = '' then begin
    messagedlg('You must enter a command',mtinformation,[mbok],0);
    EditRCommand.setfocus;
    exit;
  end;
  if EditRReverse.text = '' then begin
    messagedlg('You must enter a reverse to the command',mtinformation,[mbok],0);
    EditRReverse.setfocus;
    exit;
  end;
  EditRCommand.text:=Datawell.CutTrailingSpaces(EditRCommand.text);
  EditRReverse.text:=Datawell.CutTrailingSpaces(EditRReverse.text);
  table:=TClientDataset.create(self);
  with table do begin
    CloneCursor(Datawell.TableReverse, false);
    filtered := true;
    active:=true;
    didfind:=false;
    first;
    while not EOF do begin
      if fieldbyname('Command').asstring = EditRCommand.text then begin
        didfind:=true;
        break;
      end;
      next;
    end;
    didfind2:=false;
    first;
    while not EOF do begin
      if fieldbyname('Command').asstring = EditRReverse.text then begin
        didfind2:=true;
        break;
      end;
      next;
    end;
  end;
  table.free;
  if didfind then begin
    messagedlg('That command is already reverseed',mtinformation,[mbok],0);
    EditRCommand.selectall;
    EditRCommand.setfocus;
    exit;
  end;
  rbypass:=true;
  if (CheckDuplicate.checked) and (not didfind2) and
    (EditRCommand.text <> EditRReverse.text) then begin
    Datawell.TableReverse.append;
    Datawell.TableReverse.fieldbyname('Master').asinteger:=Datawell.masterinteger;
    Datawell.TableReverse.fieldbyname('Command').asstring:=EditRReverse.text;
    Datawell.TableReverse.fieldbyname('Reverse').asstring:=EditRCommand.text;
    Datawell.TableReverse.post;
  end;
  Datawell.TableReverse.append;
  Datawell.TableReverse.fieldbyname('Master').asinteger:=Datawell.masterinteger;
  Datawell.TableReverse.fieldbyname('Command').asstring:=EditRCommand.text;
  Datawell.TableReverse.fieldbyname('Reverse').asstring:=EditRReverse.text;
  Datawell.TableReverse.post;
  rbypass:=false;
  EditRCommand.text:='';
  EditRReverse.text:='';
  CheckDuplicate.checked:=true;
  EditRCommand.setfocus;
end;

procedure TFormOptions.BtnClearBeepClick(Sender: TObject);
begin
  EditSound.text:='';
end;

procedure TFormOptions.SpinMaxEventsExit(Sender: TObject);
begin
  with TJvDBSpinEdit(sender) do begin
    if value < 3 then value:=3;
  end;
end;

procedure TFormOptions.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = VK_DELETE then begin
    if activecontrol = GridReverse then begin
      BtnRDelete.click;
      key:=0;
    end;
    if activecontrol = GridRetain then begin
      BtnDelete.click;
      key:=0;
    end;
  end;
end;

procedure TFormOptions.SpinIHExit(Sender: TObject);
begin
  with TJvDBSpinEdit(sender) do begin
    if value > 9000 then value:=9000;
    if value < 50 then value:=50;
  end;
end;

procedure TFormOptions.BtnClearClick(Sender: TObject);
var
  tab: integer;
  all, doreset: boolean;
begin
  all:=false;
  doreset:=false;
  if TBitBtn(sender).tag = 1 then all:=true;
  if all then begin
    if messagedlg('Reset all options to default?',
      mtconfirmation,[mbyes,mbno],0) = mrno then exit;
  end;
  if TabOptions.activepage = PageMessages then tab:=0
  else if TabOptions.activepage = PageMedia then tab:=1
  else if TabOptions.activepage = PageStatusBars then tab:=2
  else if TabOptions.activepage = PageText then tab:=3
  else if TabOptions.activepage = PageCommandLine then tab:=4
  else if TabOptions.activepage = PageReversing then tab:=5
  else if TabOptions.activepage = PageKeyhistory then tab:=6
  else if TabOptions.activepage = PageFTP then tab:=7
  else tab:=8;
//General
  if (tab = 0) or (all) then begin
    SpinScroll.value:=999;
    SpinLinewrap.value:=80;
    CheckEnableChat.checked:=false;
    CheckEnableTell.checked:=false;
    CheckPageup.checked:=true;
    CheckFeed.checked:=true;
    CheckLabels.checked:=true;
    CheckClearSending.checked:=true;
    CheckEscape.checked:=false;
    CheckAltF4.checked:=true;
    CheckMenu.checked:=true;
    CheckDisableAliasLED.checked:=false;
    CheckPanicLock.checked:=false;
    CheckPanicBeep.checked:=false;
    CheckIdle.checked:=false;
    SpinIdle.value:=300;
    CheckScrollExit.checked:=true;
    CheckAutoKillSecondary.checked:=true;
    EditSecondaryPrompt.text:='';
    CheckSecondaryColor.checked:=true;
    ColorGrid.foregroundindex:=6;
    Check2Italics.checked:=true;
    ColorPrimary.brush.color:=clgray;
    ColorSecondary.brush.color:=clyellow;
    CheckWarnBreak.checked:=true;
  end;
//Media
  if (tab = 1) or (all) then begin
    EditSound.text:='';
    CheckAutoShowImagery.checked:=true;
    CheckAutoExpandImagery.checked:=true;
    SpinIH.value:=300;
    SpinIW.value:=300;
    CheckEnableRemote.checked:=true;
    CheckAutoDownload.checked:=true;
    CheckNotify.checked:=true;
    CheckAutoPlay.checked:=false;
    CheckSounds.checked:=true;
  end;
//Status Bars
  if (tab = 2) or (all) then begin
    EditHPMask.text:='Hit Points';
    EditSPMask.text:='Spell Points';
    MaskGP1.text:='Guild Points 1';
    MaskGP2.text:='Guild Points 2';
    CheckHP.checked:=true;
    CheckSP.checked:=true;
    CheckGP1.checked:=true;
    CheckGP2.checked:=true;
    CheckEnemy.checked:=true;
    cl1.brush.color:=clred;
    cl2.brush.color:=clred;
    cl3.brush.color:=clred;
    cl4.brush.color:=clred;
    cl5.brush.color:=clred;
    SpinHP.value:=25;
    SpinSP.value:=25;
    SpinGP1.value:=25;
    SpinGP2.value:=25;
    SpinEnemy.value:=25;
    cm1.brush.color:=clyellow;
    cm2.brush.color:=clyellow;
    cm3.brush.color:=clyellow;
    cm4.brush.color:=clyellow;
    cm5.brush.color:=clyellow;
    SpinHP2.value:=50;
    SpinSP2.value:=50;
    SpinGP12.value:=50;
    SpinGP22.value:=50;
    SpinEnemy2.value:=50;
    ch1.brush.color:=clgreen;
    ch2.brush.color:=clgreen;
    ch3.brush.color:=clgreen;
    ch4.brush.color:=clgreen;
    ch5.brush.color:=clgreen;
    c1001.brush.color:=cllime;
    c1002.brush.color:=cllime;
    c1003.brush.color:=cllime;
    c1004.brush.color:=cllime;
    c1005.brush.color:=cllime;
    co1.brush.color:=claqua;
    co2.brush.color:=claqua;
    co3.brush.color:=claqua;
    co4.brush.color:=claqua;
    co5.brush.color:=claqua;
    Color21.brush.color:=claqua;
    Color22.brush.color:=claqua;
    SpinSpecialDuration.value:=5;
    Color666.brush.color:=clsilver;
    CheckShowText.checked:=false;
    CheckStatus.checked:=false;
  end;
//Text Options
  if (tab = 3) or (all) then begin
    fcolors[0]:=15; bcolors[0]:=12;
    fcolors[1]:=15; bcolors[1]:=1;
    fcolors[5]:=15; bcolors[5]:=7;
    fcolors[2]:=15; bcolors[2]:=2;
    fcolors[3]:=15; bcolors[3]:=3;
    fcolors[4]:=15; bcolors[4]:=5;
    fcolors[8]:=15; bcolors[8]:=4;
    fcolors[9]:=9; bcolors[9]:=4;
    fcolors[10]:=11; bcolors[10]:=4;
    fcolors[11]:=10; bcolors[11]:=4;
    fcolors[7]:=11; bcolors[7]:=9;
    fcolors[6]:=15; bcolors[6]:=8;
    fcolors[12]:=10; bcolors[12]:=0;
    fcolors[13]:=14; bcolors[13]:=0;
    CheckTyped.checked:=true;
    CheckAutotyper.checked:=true;
    CheckPasted.checked:=true;
    CheckAliases.checked:=true;
    CheckMacros.checked:=true;
    CheckEvents.checked:=true;
    CheckEQuickchars.checked:=true;
    CheckETicker.checked:=true;
    CheckEParsed.checked:=true;
    CheckESprint.checked:=true;
    ColorTyped.font.color:=clwhite; ColorTyped.color:=clblue;
    ColorAutotyper.font.color:=clwhite; ColorAutotyper.color:=clmaroon;
    ColorPasted.font.color:=clwhite; ColorPasted.color:=clsilver;
    ColorAliases.font.color:=clwhite; ColorAliases.color:=clgreen;
    ColorMacros.font.color:=clwhite; ColorMacros.color:=clolive;
    ColorEvents.font.color:=clwhite; ColorEvents.color:=clpurple;
    ColorQuickchars.font.color:=clwhite; ColorQuickchars.color:=clnavy;
    ColorTicker.font.color:=clyellow; ColorTicker.color:=clnavy;
    ColorParsed.font.color:=cllime; ColorParsed.color:=clnavy;
    ColorSelected.font.color:=clyellow; ColorSelected.color:=clred;
    ColorSystem.font.color:=clwhite; ColorSystem.color:=clgray;
    ColorHyperlink.font.color:=cllime; ColorHyperlink.color:=clblack;
    ColorSprint.font.color:=claqua; ColorSprint.color:=clblack;
    CheckNTyped.checked:=true;
    CheckNAutotyper.checked:=false;
    CheckNPasted.checked:=true;
    CheckNAliases.checked:=true;
    CheckNMacros.checked:=true;
    CheckNEvents.checked:=true;
    CheckNQuickchars.checked:=true;
    CheckNTicker.checked:=true;
    CheckNParsed.checked:=true;
    CheckNSprint.checked:=true;
    CheckDTyped.checked:=false;
    CheckDAutotyper.checked:=false;
    CheckDPasted.checked:=false;
    CheckDAliases.checked:=false;
    CheckDMacros.checked:=false;
    CheckDEvents.checked:=false;
    CheckDQuickchars.checked:=false;
    CheckDTicker.checked:=false;
    CheckDParsed.checked:=false;
    CheckDSprint.checked:=false;
    CheckVTyped.checked:=false;
    CheckVAutotyped.checked:=false;
    CheckVPasted.checked:=true;
    CheckVAliases.checked:=true;
    CheckVMacros.checked:=true;
    CheckVEvents.checked:=true;
    CheckVQuickchars.checked:=true;
    CheckVTicker.checked:=true;
    CheckVParsed.checked:=true;
    CheckVSprint.checked:=true;
    CheckFTyped.checked:=false;
    CheckFAutotyped.checked:=false;
    CheckFPasted.checked:=true;
    CheckFAliases.checked:=true;
    CheckFMacros.checked:=true;
    CheckFEvents.checked:=true;
    CheckFQuickchars.checked:=true;
    CheckFTicker.checked:=true;
    CheckFParsed.checked:=true;
    CheckFSprint.checked:=true;
    CheckBTyped.checked:=false;
    CheckBAutotyped.checked:=false;
    CheckBAliases.checked:=false;
    CheckBMacros.checked:=false;
    CheckBEvents.checked:=false;
    CheckBPasted.checked:=false;
    CheckBQuickchars.checked:=false;
    CheckBTicker.checked:=false;
    CheckBParsed.checked:=false;
    CheckBSprint.checked:=false;
    CheckEnableHyperlinks.checked:=true;
    CheckAutocopy.checked:=true;
    CheckPCorrect.checked:=false;
    CheckPureLine.checked:=false;
    CheckForced.checked:=true;
    CheckFullFlash.checked:=false;
    CheckMaskPassword.checked:=false;
    CheckTab.checked:=false;
    EditActivator.itemindex:=EditActivator.items.indexof(';');
    EditQuickchar.itemindex:=EditQuickchar.items.indexof('"');
  end;
//Command Line
  if (tab = 4) or (all) then begin
    CheckTruncate.checked:=false;
    CheckAutoExpand.checked:=true;
  end;
//Keyhistory
  if (tab = 5) or (all) then begin
    SpinHistory.value:=50;
    SpinChars.value:=3;
    CheckActiveKeyhistory.checked:=false;
    CheckHighlightKeyhistory.checked:=true;
    CheckTabCompletion.checked:=true;
    SpinTabBuffer.value:=250;
    SpinTabChars.value:=4;
    CheckTabLowercase.checked:=true;
    EditTab1.text:='';
    EditTab2.text:='';
    EditTab3.text:='';
    EditTab4.text:='';
    EditTab5.text:='';
    EditTab6.text:='';
    EditTab7.text:='';
    EditTab8.text:='';
  end;
//Reversing
  if (tab = 6) or (all) then begin
    CheckRetain.checked:=false;
    CheckRetainAll.checked:=false;
  end;
//FTP Emulation
  if (tab = 7) or (all) then begin
    CheckDelayUpload.checked:=true;
    CheckLocalDir.checked:=false;
    try DirectoryLocal.directory:=datawell.exedir;
      except on EInOutError do end;
    if doreset then begin
      try DirectoryLocal.directory:='c:';
        except on EInOutError do end;
    end;
    CheckOverwriteLocal.checked:=false;
    CheckCopyFilename.checked:=true;
  end;
//Global Options
  if (tab = 8) or (all) then begin
    CheckWarnings.checked:=true;
    CheckBackup.checked:=false;
    SpinMaxEvents.value:=5;
    CheckPersistentCLH.checked:=false;
    CheckProfanity.checked:=false;
    CheckReconnect.checked:=false;
  end;
  UpdateRetain;
end;

procedure TFormOptions.SpinHistoryChange(Sender: TObject);
begin
  with TJvDBSpinEdit(sender) do begin
    if value > 999 then value:=999;
    if value < 0 then value:=0;
  end;
end;

procedure TFormOptions.SpinScrollChange(Sender: TObject);
begin
  with TJvDBSpinEdit(sender) do begin
    if value > 99999 then value:=99999;
    if value < 0 then value:=0;
  end;
end;

procedure TFormOptions.SpinLinewrapChange(Sender: TObject);
begin
  with TJvDBSpinEdit(sender) do begin
    if value > 160 then value:=160;
    if value < 20 then value:=20;
  end;
end;

end.
